package person.bing.fbcloud.common.core.util;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import person.bing.fbcloud.common.core.constant.CommonConstant;

import java.io.Serializable;

/**
 * @Author: mengfanbing
 * @Date: 2019/4/22 11:11
 */

@Builder
@Data
@AllArgsConstructor
public class R<T> implements Serializable{
    private static final long serialVersionUID = 1L;

    private int code = 0;
    private String msg = "true";
    private T data;

    public R(){}

    public R(T data){
        this.data = data;
    }

    public R(String msg, T data){
        this.msg = msg;
        this.data = data;
    }

    public R(Throwable throwable){
        this.code = CommonConstant.FAIL;
        this.msg = throwable.getMessage();

    }
}
